﻿function changetText(source) {
    var row_id = source.id.substr(11, source.id.lastIndexOf('_'));
    var arr = new Array();
    var arr = row_id.split("_");
    var ids = arr[0];
    var num = parseInt(ids) - 1;

    var rCell1 = document.getElementById("gvThier").rows[num].cells[0].innerHTML;
    var rCell2 = document.getElementById("gvThier").rows[1].cells[1].innerHTML;
    var rCell3 = document.getElementById("gvThier").rows[1].cells[2].innerHTML;
    var rCell4 = document.getElementById("gvThier").rows[1].cells[3].innerHTML;
    //	      var rCell5=document.getElementById("gvThier").rows[num].cells[4].innerHTML;

    var ar = new Array();
    var ar = rCell1.split(" ");

    var cc = new Array();
    var cc = ar[3].split("=")

    var ars = new Array();
    var ars = rCell2.split(" ");
    var ccs = new Array();
    var ccs = ars[3].split("=")

    var ars3 = new Array();
    var ars3 = rCell3.split(" ");
    var ccs3 = new Array();
    var ccs3 = ars3[3].split("=")

    var ars4 = new Array();
    var ars4 = rCell4.split(" ");
    var ccs4 = new Array();
    var ccs4 = ars4[3].split("=")

    if (cc[1] == "一、经营活动产生的现金流入" || cc[1] == "二、投资活动产生的现金流入" || cc[1] == "三、筹资活动产生的现金流入") {
        var to1 = "0"; var to2 = "0"; var to3 = "0";

        for (var n = 1; n < 9; n++) {
            var rCelld = document.getElementById("gvThier").rows[n].cells[0].innerHTML;
            var ara = new Array();
            var ara = rCelld.split(" ");

            var cca = new Array();
            var cca = ara[3].split("=")

            //  alert(cca[1])

            if (cca[1] == "一、经营活动产生的现金流入1")// ||(cc[1]=="二、投资活动产生的现金流入")||(cc[1]=="三、筹资活动产生的现金流入"))
            {
                var sum = document.getElementById("gvThier").rows[n].cells[1].innerHTML;
                var a1r = new Array();
                var a1r = sum.split(" ");
                var c1c = new Array();
                var c1c = a1r[6].split("=");
                to1 = parseFloat(to1) + parseFloat(c1c[1]);

                alert("to1=" + to1);
                var sum2 = document.getElementById("gvThier").rows[n].cells[2].innerHTML;
                var a2r = new Array();
                var a2r = sum2.split(" ");
                var c2c = new Array();
                var c2c = a2r[6].split("=");
                to2 = parseFloat(to2) + parseFloat(c2c[1]);
                alert("to2=" + to2);
                var sum3 = document.getElementById("gvThier").rows[n].cells[3].innerHTML;
                var a3r = new Array();
                var a3r = sum3.split(" ");
                var c3c = new Array();
                var c3c = a3r[6].split("=");
                to3 = parseFloat(to3) + parseFloat(c3c[1]); alert("to3=" + to3);
            } else if (cc[1] == "二、投资活动产生的现金流入") {
                var sum = document.getElementById("gvThier").rows[n].cells[1].innerHTML;
                var a1r = new Array();
                var a1r = sum.split(" ");
                var c1c = new Array();
                var c1c = a1r[6].split("=");
                to1 = parseFloat(to1) + parseFloat(c1c[1]);

                alert("to1=" + to1);
                var sum2 = document.getElementById("gvThier").rows[n].cells[2].innerHTML;
                var a2r = new Array();
                var a2r = sum2.split(" ");
                var c2c = new Array();
                var c2c = a2r[6].split("=");
                to2 = parseFloat(to2) + parseFloat(c2c[1]);
                alert("to2=" + to2);
                var sum3 = document.getElementById("gvThier").rows[n].cells[3].innerHTML;
                var a3r = new Array();
                var a3r = sum3.split(" ");
                var c3c = new Array();
                var c3c = a3r[6].split("=");
                to3 = parseFloat(to3) + parseFloat(c3c[1]); alert("to3=" + to3);
            } else if (cc[1] == "三、筹资活动产生的现金流入") {
                var sum = document.getElementById("gvThier").rows[n].cells[1].innerHTML;
                var a1r = new Array();
                var a1r = sum.split(" ");
                var c1c = new Array();
                var c1c = a1r[6].split("=");
                to1 = parseFloat(to1) + parseFloat(c1c[1]);

                alert("to1=" + to1);
                var sum2 = document.getElementById("gvThier").rows[n].cells[2].innerHTML;
                var a2r = new Array();
                var a2r = sum2.split(" ");
                var c2c = new Array();
                var c2c = a2r[6].split("=");
                to2 = parseFloat(to2) + parseFloat(c2c[1]);
                alert("to2=" + to2);
                var sum3 = document.getElementById("gvThier").rows[n].cells[3].innerHTML;
                var a3r = new Array();
                var a3r = sum3.split(" ");
                var c3c = new Array();
                var c3c = a3r[6].split("=");
                to3 = parseFloat(to3) + parseFloat(c3c[1]); alert("to3=" + to3);
            }
        }

        alert(ccs[1]);
        document.getElementById(ccs[1]).value = to1;
        document.getElementById(ccs3[1]).value = to2;
        document.getElementById(ccs4[1]).value = to3;
        // document.getElementById(c12c[1]).value=parseFloat(c1c[1])+parseFloat(c2c[1]);
    }
}

//            for(var n=1;n<4;n++)
//                {
//                var sum=document.getElementById("gvThier").rows[1].cells[n].innerHTML;
//                var a1r = new Array();
//                var a1r=sum.split(" ");
//	            var c1c = new Array();
//	            var c1c=a1r[6].split("=");
//
//	            var c12c=a1r[3].split("=");
//	            var sum=document.getElementById("gvThier").rows[num].cells[n].innerHTML;
//                var a2r = new Array();
//                var a2r=sum.split(" ");
//	            var c2c = new Array();
//	            var c2c=a2r[6].split("=");
//
//
//
//	            document.getElementById(c12c[1]).value=parseFloat(c1c[1])+parseFloat(c2c[1]);
//	            }
//	      }
//	    else  if(cc[1]=="二、投资活动产生的现金流入")
//	      {
//            for(var n=1;n<4;n++)
//                {
//                var sum=document.getElementById("gvThier").rows[1].cells[n].innerHTML;
//                var a1r = new Array();
//                var a1r=sum.split(" ");
//	            var c1c = new Array();
//	            var c1c=a1r[6].split("=");
//
//	            var c12c=a1r[3].split("=");
//	            var sum=document.getElementById("gvThier").rows[num].cells[n].innerHTML;
//                var a2r = new Array();
//                var a2r=sum.split(" ");
//	            var c2c = new Array();
//	            var c2c=a2r[6].split("=");
//	            document.getElementById(c12c[1]).value=parseFloat(c1c[1])+parseFloat(c2c[1]);
//	            }
//	      }
//	      else  if(cc[1]=="三、筹资活动产生的现金流入")
//	      {
//            for(var n=1;n<4;n++)
//                {
//                var sum=document.getElementById("gvThier").rows[1].cells[n].innerHTML;
//                var a1r = new Array();
//                var a1r=sum.split(" ");
//	            var c1c = new Array();
//	            var c1c=a1r[6].split("=");
//
//	            var c12c=a1r[3].split("=");
//	            var sum=document.getElementById("gvThier").rows[num].cells[n].innerHTML;
//                var a2r = new Array();
//                var a2r=sum.split(" ");
//	            var c2c = new Array();
//	            var c2c=a2r[6].split("=");
//	            document.getElementById(c12c[1]).value=parseFloat(c1c[1])+parseFloat(c2c[1]);
//	            }
//	      }else{
//	       for(var n=0;n<5;n++)
//                {
//	      document.getElementById("gvThier").rows[1].cells[n].innerHTML=
//	      document.getElementById("gvThier").rows[1].cells[n].innerHTML;
//                }
//	      }
//	  }